import { Alert } from 'react-native';
import { store } from './store';


export function $fetch(url, type, params, callback) {
    // 获取默认地址
    let token = store.getState().token
    let defaultURL = store.getState().assestURL
    fetch(`${defaultURL}${url}`, {
        method: type,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            "token": token
        },
        body: params
    }).then(e => e.json()).then(data => {
        callback(data)
    })

}